package com.sxg;

import com.sxg.entity.SxgCommentEntity;
import com.sxg.service.SxgCommentService;
import com.sxg.service.SxgUserService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

//@SpringBootTest
public class test {

    @Resource
    private SxgUserService sxgUserService;

    @Resource
    private SxgCommentService sxgCommentService;

//    @Test
    void test01() {
        List<SxgCommentEntity> sxgCommentEntities = sxgCommentService.getBaseMapper().selectList(null);
        List<SxgCommentEntity> collect = sxgCommentEntities.stream().filter(sxgCommentEntity -> sxgCommentEntity.getParentId() != 0).collect(Collectors.toList());
        List<SxgCommentEntity> collect1 = collect.stream().peek(sxgCommentEntity -> {
            Long parentId = sxgCommentEntity.getParentId();
            SxgCommentEntity byId = sxgCommentService.getById(parentId);
            sxgCommentEntity.setReplayUserId(byId.getUserId());
        }).collect(Collectors.toList());
        sxgCommentService.updateBatchById(collect1);

    }

}
